<?php

namespace App\Providers;

use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;

class AuthServiceProvider extends ServiceProvider
{
    /**
     * The policy mappings for the application.
     *
     * @var array
     */
    protected $policies = [
        // 'App\Model' => 'App\Policies\ModelPolicy',
    ];

    /**
     * Register any authentication / authorization services.
     *
     * @return void
     */
    public function boot()
    {
        $this->registerPolicies();

        // 通过资源模型推断策略类
        // Specify a callback to be used to guess policy names.
        // 由gate的实现类Illuminate\Auth\Access\Gate决定
        Gate::guessPolicyNamesUsing(function ($class) {
            return '\\App\\Policies\\' . class_basename($class) . 'Policy';
        });
    }
}
